<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Custom Scales</title>
		<meta name="viewport" content="width=device-width, initial-scale=1">

		<link rel="stylesheet" href="../dist/uPlot.min.css">
		<style>
			.uplot {
				display: inline-block;
			}
		</style>
	</head>
	<body>
		<script src="../dist/uPlot.iife.js"></script>
		<script>
			let data = [
				[
					0.0,
					0.4232666594038496,
					0.8465333188076992,
					1.2697999782115488,
					1.6930666376153984,
					2.116333297019248,
					2.5395999564230975,
					2.962866615826947,
					3.386133275230797,
					3.8093999346346465,
					4.232666594038496,
					4.655933253442345,
					5.079199912846195,
					5.502466572250045,
					5.925733231653894,
					6.348999891057744,
					6.772266550461594,
					7.195533209865443,
					7.618799869269293,
					8.042066528673143,
					8.465333188076992,
					8.888599847480842,
					9.31186650688469,
					9.735133166288541,
					10.15839982569239,
					10.58166648509624,
					11.00493314450009,
					11.42819980390394,
					11.851466463307789,
					12.27473312271164,
					12.697999782115488,
					13.121266441519339,
					13.544533100923188,
					13.967799760327036,
					14.391066419730887,
					14.814333079134736,
					15.237599738538586,
					15.660866397942435,
					16.084133057346286,
					16.507399716750136,
					16.930666376153983,
					17.353933035557834,
					17.777199694961684,
					18.200466354365535,
					18.62373301376938,
					19.046999673173232,
					19.470266332577083,
					19.893532991980933,
					20.31679965138478,
					20.74006631078863,
					21.16333297019248,
					21.58659962959633,
					22.00986628900018,
					22.43313294840403,
					22.85639960780788,
					23.279666267211727,
					23.702932926615578,
					24.12619958601943,
					24.54946624542328,
					24.972732904827126,
					25.395999564230976,
					25.819266223634827,
					26.242532883038677,
					26.665799542442524,
					27.089066201846375,
					27.512332861250226,
					27.935599520654073,
					28.358866180057923,
					28.782132839461774,
					29.205399498865624,
					29.62866615826947,
					30.051932817673322,
					30.475199477077172,
					30.898466136481023,
					31.32173279588487,
					31.74499945528872,
					32.16826611469257,
					32.59153277409642,
					33.01479943350027,
					33.43806609290412,
					33.861332752307966,
					34.28459941171182,
					34.70786607111567,
					35.13113273051952,
					35.55439938992337,
					35.97766604932722,
					36.40093270873107,
					36.82419936813491,
					37.24746602753876,
					37.670732686942614,
					38.093999346346465,
					38.517266005750315,
					38.940532665154166,
					39.363799324558016,
					39.78706598396187,
					40.21033264336571,
					40.63359930276956,
					41.05686596217341,
					41.48013262157726,
					41.90339928098111,
					42.32666594038496,
					42.74993259978881,
					43.17319925919266,
					43.59646591859651,
					44.01973257800036,
					44.44299923740421,
					44.86626589680806,
					45.28953255621191,
					45.71279921561576,
					46.13606587501961,
					46.559332534423454,
					46.982599193827305,
					47.405865853231155,
					47.829132512635006,
					48.25239917203886,
					48.67566583144271,
					49.09893249084656,
					49.5221991502504,
					49.94546580965425,
					50.3687324690581,
					50.79199912846195,
					51.2152657878658,
					51.638532447269654,
					52.061799106673504,
					52.485065766077355,
					52.9083324254812,
					53.33159908488505,
					53.7548657442889,
					54.17813240369275,
					54.6013990630966,
					55.02466572250045,
					55.4479323819043,
					55.871199041308145,
					56.294465700711996,
					56.717732360115846,
					57.1409990195197,
					57.56426567892355,
					57.9875323383274,
					58.41079899773125,
					58.8340656571351,
					59.25733231653894,
					59.68059897594279,
					60.103865635346644,
					60.527132294750494,
					60.950398954154345,
					61.373665613558195,
					61.796932272962046,
					62.22019893236589,
					62.64346559176974,
					63.06673225117359,
					63.48999891057744,
					63.91326556998129,
					64.33653222938514,
					64.75979888878899,
					65.18306554819284,
					65.6063322075967,
					66.02959886700054,
					66.4528655264044,
					66.87613218580825,
					67.29939884521208,
					67.72266550461593,
					68.14593216401978,
					68.56919882342363,
					68.99246548282748,
					69.41573214223133,
					69.83899880163519,
					70.26226546103904,
					70.68553212044289,
					71.10879877984674,
					71.53206543925059,
					71.95533209865444,
					72.37859875805829,
					72.80186541746214,
					73.22513207686599,
					73.64839873626983,
					74.07166539567368,
					74.49493205507753,
					74.91819871448138,
					75.34146537388523,
					75.76473203328908,
					76.18799869269293,
					76.61126535209678,
					77.03453201150063,
					77.45779867090448,
					77.88106533030833,
					78.30433198971218,
					78.72759864911603,
					79.15086530851988,
					79.57413196792373,
					79.99739862732757,
					80.42066528673142,
					80.84393194613527,
					81.26719860553912,
					81.69046526494297,
					82.11373192434682,
					82.53699858375067,
					82.96026524315452,
					83.38353190255837,
					83.80679856196222,
					84.23006522136608
				],
				[
					0.0,
					0.009184711979382445,
					0.020281258308022358,
					0.03226148913426625,
					0.044853029853894465,
					0.05791369980105887,
					0.07135344929811757,
					0.08510900433099382,
					0.09913286567063712,
					0.11338768515669033,
					0.1278430610476992,
					0.1424735633217145,
					0.15725744227350574,
					0.17217574324826157,
					0.18721167603015132,
					0.2023501510110161,
					0.21757742863183152,
					0.23288084818173294,
					0.2482486137213587,
					0.2636696221339574,
					0.27913332294084076,
					0.29462960257041987,
					0.3101486878328026,
					0.3256810647771567,
					0.34121741011330614,
					0.3567485330989644,
					0.3722653263178452,
					0.3877587241597211,
					0.4032196681004261,
					0.4186390780945366,
					0.4340078295544977,
					0.4493167355104476,
					0.4645565336342222,
					0.47971787787586284,
					0.494791334506396,
					0.509767382390553,
					0.5246364173303251,
					0.5393887603271685,
					0.5540146696091641,
					0.568504356261057,
					0.5828480032812549,
					0.5970357878717576,
					0.6110579067457195,
					0.6249046042139721,
					0.6385662027872826,
					0.6520331360063145,
					0.6652959831870603,
					0.6783455057466694,
					0.6911726847538904,
					0.7037687593304058,
					0.7161252655147521,
					0.7282340751898042,
					0.7400874346683737,
					0.7516780025296147,
					0.7629988863019345,
					0.7740436775960002,
					0.7848064853043389,
					0.7952819665017659,
					0.8054653547033775,
					0.8153524851637173,
					0.824939816931773,
					0.8342244514111037,
					0.8432041472123033,
					0.8518773311254819,
					0.860243105083049,
					0.8683012490270878,
					0.8760522196404557,
					0.8834971449457412,
					0.8906378148207603,
					0.8974766675227284,
					0.9040167723550245,
					0.9102618086500124,
					0.9162160412781662,
					0.9218842929273504,
					0.927271913426055,
					0.9323847464104276,
					0.9372290936567341,
					0.941811677418279,
					0.946139601118646,
					0.9502203087613849,
					0.9540615434199132,
					0.9576713051705994,
					0.961057808826805,
					0.9642294418223705,
					0.9671947225798664,
					0.969962259682212,
					0.9725407121463688,
					0.9749387510751172,
					0.9771650229378457,
					0.9792281147042792,
					0.9811365210265746,
					0.9828986136356781,
					0.9845226130877365,
					0.9860165629660864,
					0.9873883066143709,
					0.9886454664470092,
					0.9897954258549668,
					0.9908453136978451,
					0.9918019913480479,
					0.9926720422294089,
					0.9934617637714159,
					0.9941771616811786,
					0.9948239464186933,
					0.9954075317468296,
					0.9959330352158221,
					0.9964052804329007,
					0.9968288009609707,
					0.9972078456858974,
					0.9975463854898221,
					0.9978481210679239,
					0.9981164917279587,
					0.9983546850155929,
					0.9985656470137977,
					0.9987520931711876,
					0.9989165195219598,
					0.9990612141688149,
					0.9991882689097121,
					0.9992995908993233,
					0.9993969142464263,
					0.9994818114590275,
					0.9995557046595666,
					0.999619876502988,
					0.9996754807406277,
					0.9997235523826411,
					0.9997650174210031,
					0.9998007020838553,
					0.9998313416000928,
					0.9998575884605464,
					0.9998800201688691,
					0.999899146481287,
					0.9999154161397071,
					0.9999292231073029,
					0.9999409123196402,
					0.9999507849676949,
					0.999959103331777,
					0.9999660951874597,
					0.9999719578061622,
					0.9999768615740995,
					0.9999809532539337,
					0.9999843589137062,
					0.9999871865475286,
					0.9999895284121243,
					0.9999914631026882,
					0.9999930573907037,
					0.9999943678453735,
					0.9999954422592213,
					0.9999963208972287,
					0.9999970375876355,
					0.999997620671251,
					0.9999980938248546,
					0.9999984767729913,
					0.9999987859012391,
					0.999999034782832,
					0.9999992346293786,
					0.9999993946753462,
					0.99999952250496,
					0.9999996243292303,
					0.9999997052199427,
					0.9999997693066531,
					0.9999998199419898,
					0.9999998598399111,
					0.9999998911909637,
					0.9999999157580534,
					0.9999999349557656,
					0.9999999499158437,
					0.9999999615410676,
					0.9999999705494396,
					0.9999999775103053,
					0.9999999828737851,
					0.999999986994674,
					0.9999999901517896,
					0.9999999925635819,
					0.9999999944006849,
					0.9999999957959793,
					0.9999999968526299,
					0.9999999976504859,
					0.9999999982511613,
					0.9999999987020523,
					0.9999999990395061,
					0.9999999992913102,
					0.9999999994786418,
					0.9999999996175903,
					0.9999999997203411,
					0.9999999997960943,
					0.9999999998517736,
					0.9999999998925734,
					0.9999999999223785,
					0.9999999999440847,
					0.999999999959844,
					0.99999999997125,
					0.9999999999794795,
					0.9999999999853987,
					0.9999999999896427,
					0.9999999999926761,
					0.9999999999948372,
					0.9999999999963721,
					0.9999999999974588,
					0.9999999999982255,
					0.9999999999987649,
					0.9999999999991431
				],
				[
					0.0,
					4.294401433226199e-06,
					3.094196536585795e-05,
					9.786987899389214e-05,
					0.0002210266349119428,
					0.0004150396007096866,
					0.0006934817014608246,
					0.0010690142127188166,
					0.0015534723746050657,
					0.002157919799050869,
					0.0028926841032873617,
					0.0037673805578731317,
					0.004790927822444934,
					0.005971558397203828,
					0.007316825587086812,
					0.008833608266774163,
					0.010528114406039714,
					0.012405884092188266,
					0.014471792628334186,
					0.016730054169215625,
					0.019184226265743037,
					0.021837215616621098,
					0.024691285264479966,
					0.027748063421337114,
					0.031008554061497124,
					0.034473149377641,
					0.038141644156880004,
					0.04201325209736171,
					0.04608662405229612,
					0.050359868156881926,
					0.054830571764550175,
					0.059495825092281907,
					0.06435224645062412,
					0.06939600891258002,
					0.07462286825694235,
					0.08002819200601222,
					0.08560698936512687,
					0.09135394186208029,
					0.09726343447840617,
					0.10332958706158217,
					0.10954628580744537,
					0.11590721460536868,
					0.1224058860448441,
					0.1290356718908693,
					0.13578983284663246,
					0.14266154743518467,
					0.14964393984671662,
					0.15673010661440345,
					0.16391314199917362,
					0.17118616198184605,
					0.17854232677952678,
					0.1859748618216084,
					0.193477077138888,
					0.20104238513690698,
					0.20866431674138824,
					0.21633653591938184,
					0.22405285259426083,
					0.23180723398589417,
					0.2395938144190745,
					0.24740690365353735,
					0.2552409937976408,
					0.2630907648750073,
					0.27095108911918564,
					0.2788170340757294,
					0.2866838645941089,
					0.2945470437936442,
					0.30240223308830144,
					0.31024529135483553,
					0.31807227332750304,
					0.32587942730055547,
					0.3336631922170395,
					0.34142019421922454,
					0.34914724273233355,
					0.35684132614929465,
					0.36449960718002106,
					0.3721194179244007,
					0.37969825472373253,
					0.38723377284094646,
					0.3947237810155493,
					0.40216623593497314,
					0.4095592366598503,
					0.4169010190367711,
					0.4241899501282942,
					0.4314245226864074,
					0.43860334969228665,
					0.44572515898207277,
					0.45278878797550315,
					0.4597931785215671,
					0.4667373718729265,
					0.4736205037986263,
					0.4804417998426225,
					0.48720057073385414,
					0.49389620795198363,
					0.5005281794515024,
					0.5070960255456401,
					0.513599354950417,
					0.52003784098822,
					0.5264112179494631,
					0.5327192776101767,
					0.538961865902794,
					0.545138879736887,
					0.5512502639662116,
					0.5572960084980898,
					0.563276145540897,
					0.5691907469852329,
					0.5750399219142113,
					0.580823814238216,
					0.5865426004494241,
					0.592196487491371,
					0.597785710738872,
					0.6033105320836387,
					0.6087712381210119,
					0.6141681384332989,
					0.6195015639653358,
					0.6247718654879644,
					0.6299794121452773,
					0.6351245900815902,
					0.6402078011442414,
					0.6452294616584633,
					0.6501900012707051,
					0.6550898618569287,
					0.6599294964925542,
					0.6647093684808479,
					0.6694299504367145,
					0.67409172342297,
					0.6786951761363123,
					0.6832408041403459,
					0.6877291091431315,
					0.6921605983168577,
					0.6965357836573584,
					0.7008551813813024,
					0.7051193113590041,
					0.7093286965808954,
					0.7134838626558162,
					0.7175853373393659,
					0.721633650090657,
					0.7256293316558999,
					0.7295729136773228,
					0.7334649283260389,
					0.7373059079575031,
					0.7410963847883252,
					0.7448368905932341,
					0.7485279564210752,
					0.7521701123287786,
					0.7557638871322929,
					0.7593098081735443,
					0.7628084011025135,
					0.7662601896736,
					0.7696656955554679,
					0.7730254381536183,
					0.7763399344449883,
					0.7796096988238894,
					0.7828352429586698,
					0.7860170756584871,
					0.7891557027496391,
					0.7922516269609101,
					0.7953053478174371,
					0.798317361542614,
					0.8012881609675978,
					0.8042182354479755,
					0.8071080707872132,
					0.8099581491664856,
					0.8127689490805565,
					0.8155409452793517,
					0.8182746087149162,
					0.8209704064934602,
					0.8236288018321943,
					0.8262502540207058,
					0.8288352183866066,
					0.8313841462652212,
					0.8338974849730896,
					0.8363756777850669,
					0.8388191639148173,
					0.8412283784985172,
					0.8436037525815802,
					0.8459457131082365,
					0.8482546829138036,
					0.8505310807194946,
					0.8527753211296223,
					0.8549878146310578,
					0.8571689675948175,
					0.8593191822796518,
					0.8614388568375259,
					0.863528385320871,
					0.8655881576915165,
					0.8676185598311904,
					0.8696199735535028,
					0.8715927766173218,
					0.8735373427414553,
					0.8754540416205621,
					0.8773432389422153,
					0.8792052964050464,
					0.8810405717379008,
					0.8828494187199432,
					0.8846321872016508,
					0.8863892231266339,
					0.8881208685542291,
					0.8898274616828209,
					0.8915093368738269,
					0.8931668246763164
				],
				[
					0.0,
					0.000199040927573356,
					0.0007959260380886081,
					0.0017899427878707434,
					0.0031799051792755027,
					0.00496415611880449,
					0.007140570709271236,
					0.009706560466862628,
					0.012659078451380437,
					0.01599462529542991,
					0.019709256115855375,
					0.023798588288315065,
					0.028257810063547942,
					0.03308169000162145,
					0.038264587198269584,
					0.043800462275341984,
					0.04968288910539528,
					0.055905067238572144,
					0.06245983499814054,
					0.06933968320940845,
					0.07653676952519466,
					0.08404293330962863,
					0.09184971104077577,
					0.0999483521914419,
					0.10832983554650663,
					0.11698488591427181,
					0.1259039911885874,
					0.1350774197179407,
					0.14449523793725835,
					0.15414732821788296,
					0.16402340689103664,
					0.17411304240008543,
					0.18440567353705195,
					0.194890627719106,
					0.20555713926117547,
					0.21639436760136707,
					0.22739141543657,
					0.23853734672641394,
					0.24982120452468573,
					0.26123202859834593,
					0.27275887279544686,
					0.2843908221245098,
					0.29611700950927844,
					0.30792663218422317,
					0.3198089676977042,
					0.3317533894913285,
					0.3437493820257174,
					0.355786555424674,
					0.3678546596115414,
					0.37994359791341986,
					0.3920434401108155,
					0.4041444349122433,
					0.41623702183527855,
					0.4283118424775454,
					0.44035975116314074,
					0.45237182495200534,
					0.46433937300176475,
					0.4762539452735639,
					0.48810734057541605,
					0.4998916139385394,
					0.5115990833241053,
					0.5232223356597108,
					0.5347542322067611,
					0.5461879132617564,
					0.5575168021962383,
					0.5687346088418608,
					0.5798353322286957,
					0.590813262686457,
					0.6016629833198374,
					0.6123793708705909,
					0.6229575959803472,
					0.6333931228694245,
					0.643681708448109,
					0.6538194008779752,
					0.6638025376018556,
					0.6736277428620052,
					0.6832919247268598,
					0.6927922716475547,
					0.7021262485660438,
					0.711291592597249,
					0.7202863083081674,
					0.7291086626172849,
					0.73775717933796,
					0.7462306333896981,
					0.75452804470139,
					0.7626486718306705,
					0.7705920053235553,
					0.7783577608384413,
					0.7859458720584107,
					0.7933564834155571,
					0.8005899426507751,
					0.8076467932321038,
					0.8145277666543073,
					0.8212337746419112,
					0.8277659012773974,
					0.8341253950756896,
					0.8403136610254536,
					0.8463322526170738,
					0.8521828638764841,
					0.857867321423296,
					0.8633875765709105,
					0.8687456974855198,
					0.8739438614200921,
					0.8789843470386093,
					0.8838695268449825,
					0.888601859730221,
					0.8931838836505601,
					0.8976182084483932,
					0.9019075088269763,
					0.9060545174890117,
					0.9100620184483459,
					0.9139328405231676,
					0.9176698510182347,
					0.9212759496028338,
					0.9247540623903475,
					0.928107136224506,
					0.9313381331766133,
					0.9344500252572752,
					0.9374457893454156,
					0.9403284023366528,
					0.9431008365124135,
					0.9457660551305028,
					0.9483270082372102,
					0.950786628700426,
					0.953147828462666,
					0.9554134950123565,
					0.9575864880712153,
					0.9596696364950805,
					0.9616657353850889,
					0.9635775434056798,
					0.9654077803055147,
					0.9671591246370431,
					0.9688342116701177,
					0.9704356314947647,
					0.971965927307949,
					0.9734275938789374,
					0.9748230761876537,
					0.9761547682302376,
					0.9774250119858715,
					0.9786360965388062,
					0.9797902573494202,
					0.9808896756680681,
					0.9819364780854216,
					0.9829327362129745,
					0.983880466487374,
					0.9847816300922518,
					0.985638132991256,
					0.9864518260660352,
					0.9872245053529861,
					0.9879579123726606,
					0.9886537345458174,
					0.9893136056902138,
					0.9899391065923511,
					0.99053176564852,
					0.9910930595696272,
					0.9916244141444411,
					0.9921272050560457,
					0.9926027587464583,
					0.9930523533245366,
					0.993477219512474,
					0.9938785416263634,
					0.9942574585864865,
					0.9946150649531779,
					0.9949524119842903,
					0.9952705087104806,
					0.9955703230247193,
					0.9958527827826136,
					0.9961187769103204,
					0.996369156517005,
					0.9966047360089877,
					0.9968262942028951,
					0.9970345754353078,
					0.9972302906665717,
					0.9974141185766024,
					0.9975867066506814,
					0.9977486722533946,
					0.9979006036890258,
					0.9980430612468599,
					0.9981765782299981,
					0.9983016619664247,
					0.9984187948011994,
					0.9985284350687734,
					0.9986310180445525,
					0.9987269568749464,
					0.9988166434852513,
					0.99890044946482,
					0.9989787269290724,
					0.9990518093579933,
					0.9991200124108515,
					0.9991836347169565,
					0.9992429586423507,
					0.9992982510323992,
					0.9993497639303156,
					0.9993977352717162,
					0.9994423895553586,
					0.9994839384902692,
					0.9995225816195132,
					0.999558506920908,
					0.9995918913850124,
					0.9996229015707714
				],
			].map(s => {
				s.shift();
				return s;
			});

			let pointVals = [
				[
					20.55094355447392,
					52.04910458236307,
					34.42486200685348,
					28.664408216433806,
					12.355661998295018,
					12.354621108036648,
					7.338589220539095,
					42.54536141616317,
					28.76063174314045,
					33.2885123658918,
					4.32658955751811,
					56.15337681424405,
					40.09721423015828,
					14.656700267251571,
					13.43916254365193,
					13.503713583641774,
					18.06871208787249,
					25.875375316597225,
					22.560659567093843,
					17.60115602165231
				],
				[
					0.47549019607843135,
					0.9166666666666667,
					0.7696078431372549,
					0.6225490196078431,
					0.18137254901960786,
					0.13235294117647062,
					0.08333333333333334,
					0.8676470588235294,
					0.6715686274509804,
					0.7205882352941176,
					0.03431372549019608,
					0.9656862745098039,
					0.8186274509803921,
					0.32843137254901966,
					0.2303921568627451,
					0.27941176470588236,
					0.4264705882352941,
					0.5735294117647058,
					0.5245098039215687,
					0.3774509803921569
				]
			];

			const hooks = {
				draw: [
					(u) => {
						u.ctx.save();

						u.ctx.fillStyle = 'black';

						for (let i = 0; i < pointVals[0].length; i++) {
							let x = pointVals[0][i];
							let y = pointVals[1][i];

							u.ctx.fillRect(
								u.valToPos(x, 'x', true),
								u.valToPos(y, 'y', true),
								5,
								5
							);
						}

						u.ctx.restore();
					}
				]
			};

			const series = [
				{},
				{
					label: "upper_ci",
					stroke: "blue",
					width: 0,
				},
				{
					label: "lower_ci",
					stroke: "green",
					width: 0,

				},
				{
					label: "weibull_fitted",
					stroke: "orange",
					width: 2,
					dash: [10, 5],
				},
			];

			const bands = [
				{
					series: [1,2],
					fill: '#ffa50030',
					dir: -1,
				}
			];

			const width = 800;
			const height = 800;

			{
				const opts = {
					title: "x linear; y linear",
					scales: {
						x: {
							time: false,
						},
						y: {
							range: (u, min, max) => [min, max],
						}
					},
					width,
					height,
					series,
					bands,
					hooks,
				};

				let u = new uPlot(opts, data, document.body);
			}

			{
				const opts = {
					title: "log(x); log(y)",
					scales: {
						x: {
							time: false,
							distr: 3,
							log: 10,
						},
						y: {
							distr: 3,
							log: 10,
						}
					},
					width,
					height,
					series,
					bands,
					hooks,
				};

				let u = new uPlot(opts, data, document.body);
			}

			{
				const opts = {
					title: "log(x); log(-log(1 - y))",
					scales: {
						x: {
							time: false,
							distr: 3,
							log: 10,
						},
						y: {
							distr: 100,
							range: (u, min, max) => [min, max],

							fwd: v => Math.log(-Math.log(1 - v)),
							bwd: v => 1 - Math.exp(-Math.exp(v)),
						}
					},
					axes: [
						{},
						{
							size: 80,
							splits: (u) => [0.00001, 0.0001, 0.001, 0.01, 0.1, 0.2, 0.3, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999, 0.9999, 0.99999, 0.999999],
							filter: (u, values) => values,
							values: (u, splits) => splits.map(v => v == null ? '' : v.toExponential()),
						}
					],
					width,
					height,
					series,
					bands,
					hooks,
				};

				let u = new uPlot(opts, data, document.body);
			}
		</script>
	</body>
</html>